<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:rich="http://richfaces.org/rich"
      xmlns:a4j="http://richfaces.org/a4j">

	<ui:composition template="/layout/template.xhtml">
		<ui:define name="navigation">
			<h:outputText value="#{messages['layout.menu.lesson.main']}" />
		</ui:define>
		<ui:define name="title">
			<h:outputText value="#{messages['layout.menu.lesson.main']}" />
		</ui:define>
		<ui:define name="body">
			<ui:include src="lesson-edit-modal.xhtml" />
			<ui:include src="lesson-test.xhtml" />
			<a4j:form id="lessonGridForm">
				<rich:messages globalOnly="true"></rich:messages>

				<!-- BUTTON - NEW -->				
				<a4j:commandButton action="#{lessonsAction.preCreate()}"
					value="#{messages['button.new']}" reRender="lessonEditMD"
					oncomplete="Richfaces.showModalPanel('lessonEditMD');"
					ajaxSingle="true" />

				<!-- BUTTON - EDIT -->
				<a4j:commandButton action="#{lessonsAction.preEdit()}"
					value="#{messages['button.edit']}" reRender="lessonEditMD"
					oncomplete="Richfaces.showModalPanel('lessonEditMD');"
					disabled="#{!lessonsAction.isEditButtonEnabled()}"
					ajaxSingle="true" />

				<!-- BUTTON - DELETE -->
				<a4j:commandButton action="#{lessonsAction.doDelete()}"
					value="#{messages['button.delete']}" reRender="lessonGridForm"
					oncomplete="Richfaces.showModalPanel('lessonEditMD');"
					disabled="#{!lessonsAction.isDeleteButtonEnabled()}"
					ajaxSingle="true" />

				<!-- BUTTON - OUTLOOK -->
				<a4j:commandButton action="#{lessonsAction.doOutlook()}"
					value="#{messages['button.outlook']}" reRender="xxx"
					oncomplete="Richfaces.showModalPanel('lessonEditMD');"
					disabled="#{!lessonsAction.isOutlookButtonEnabled()}"
					ajaxSingle="true" />

				<!-- BUTTON - TEST -->
				<a4j:commandButton action="#{lessonsAction.doTest()}"
					value="#{messages['lesson.button.test']}" reRender="lessonTestMD"
					oncomplete="Richfaces.showModalPanel('lessonTestMD');"
					disabled="#{!lessonsAction.isTestButtonEnabled()}"
					ajaxSingle="true" />

				<!-- BUTTON - PREVIEW -->
				<a4j:commandButton action="#{lessonsAction.doPreview()}"
					value="#{messages['lesson.button.preview']}" reRender="lessonTestMD"
					oncomplete="Richfaces.showModalPanel('lessonEditMD');"
					disabled="#{!lessonsAction.isTestButtonEnabled()}"
					ajaxSingle="true" />
				 
				<!-- TABLE -->
				<rich:extendedDataTable id="dataTable"
					value="#{lessonsAction.model}" var="lessItem" selectionMode="single" 
					selection="#{lessonsAction.selection}">
					
					<rich:column label="#{messages['lesson.table.name']}">
						<f:facet name="header">#{messages['lesson.table.name']}</f:facet>
						<h:outputText value="#{lessItem.name}" title="#{lessItem.name}" />
					</rich:column>

					<rich:column label="#{messages['lesson.table.note']}">
						<f:facet name="header">#{messages['lesson.table.note']}</f:facet>
						<h:outputText value="#{lessItem.note}" title="#{lessItem.note}" />
					</rich:column>

					<rich:column label="#{messages['lesson.table.voc.type']}">
						<f:facet name="header">#{messages['lesson.table.voc.type']}</f:facet>
						<h:outputText value="#{lessItem.vocType.code}" title="#{lessItem.vocType.code}" />
					</rich:column>
					
					<a4j:support event="onselectionchange" ajaxSingle="true" reRender="lessonGridForm" />
				</rich:extendedDataTable>

			</a4j:form>
		</ui:define>
	</ui:composition>
</html>